private void setMaterialsSettings(AnimatedMeshSceneNode node)
        {
            if (node != null)
            {
                // materials with normal maps are not handled
                for (int i = 0; i < node.MaterialCount; ++i)
                {
                    Material material = node.GetMaterial(i);
                    if (material.Type == MaterialType.NormalMapSolid ||
                        material.Type == MaterialType.ParallaxMapSolid)
                    {
                        material.Type = MaterialType.Solid;
                    }
                    else if (material.Type == MaterialType.NormalMapTransparentAddColor ||
                             material.Type == MaterialType.ParallaxMapTransparentAddColor)
                    {
                        material.Type = MaterialType.TransparentAddColor;
                    }
                    else if (material.Type == MaterialType.NormalMapTransparentVertexAlpha ||
                             material.Type == MaterialType.ParallaxMapTransparentVertexAlpha)
                    {
                        material.Type = MaterialType.TransparentVertexAlpha;
                    }
                }

                node.SetMaterialFlag(MaterialFlag.Lighting, false);
                node.SetMaterialFlag(MaterialFlag.BackFaceCulling, false);

                for (int i = 1; i < 8; ++i)                 // 8 = _IRR_MATERIAL_MAX_TEXTURES_
                {
                    node.SetMaterialTexture(i, null);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Sets the material textures for the mesh.
        /// </summary>
        private void SetMaterials(VideoDriver driver, AnimatedMeshSceneNode node)
        {
            List <Material> materials = new List <Material>();

            //mat.Type = MaterialType.Solid;
            foreach (var materialInstance in cdata.materialInstances)
            {
                Material mat = new Material();
                foreach (var material in materialInstance.instanceParameters)
                {
                    switch (material.Name)
                    {
                    case "Diffuse":
                        Texture diffTexture = GetTexture(driver, (material as CHandle).Handle);
                        mat.SetTexture(0, diffTexture);
                        break;

                    case "Normal":
                        Texture normTexture = GetTexture(driver, (material as CHandle).Handle);
                        mat.SetTexture(1, normTexture);
                        //mat.Type = MaterialType.NormalMapSolid;
                        break;
                    }
                }
                materials.Add(mat);
            }
            for (int i = 0; i < cdata.meshInfos.Count; i++)
            {
                if (cdata.meshInfos[i].materialID < materials.Count)
                {
                    Material mat = materials[(int)cdata.meshInfos[i].materialID];
                    node.SetMaterialTexture(i, mat.GetTexture(i));
                }
            }
        }
Exemple #3
0
        public void Initialize()
        {
            //var light = Scene.AddLightSceneNode(Scene.RootNode,new Vector3Df(2, 6, 3), new Colorf(200, 200, 180), 20);
            var light = Scene.AddLightSceneNode(null, new Vector3Df(-30, 35, -25));

            light.Radius      = 25;
            light.CastShadows = true;
            light.LightType   = LightType.Point;

            var sun = Scene.AddLightSceneNode(null, new Vector3Df(40, 100, 40));

            sun.Radius      = 50;
            sun.CastShadows = true;
            sun.LightType   = LightType.Point;


            sphere       = Scene.AddAnimatedMeshSceneNode(Scene.AddSphereMesh("sphere", 10f));
            sphere.Scale = new Vector3Df(1);
            sphere.SetMaterialFlag(MaterialFlag.Lighting, true);
            sphere.Position = new Vector3Df(1, 11, 1);
            //sphere.SetMaterialTexture(0, Driver.GetTexture("Mars.jpg"));
            sphere.SetMaterialTexture(0, GeneratePlanetTexture(new Vector2Dd(300, 300)));
            Scene.MeshManipulator.SetVertexColors(sphere.Mesh, new Color(200, 200, 200));

            var terrain =
                Scene.AddAnimatedMeshSceneNode(Scene.AddHillPlaneMesh("terrain", new Dimension2Df(1, 1),
                                                                      new Dimension2Di(128, 128),
                                                                      new Material(), 0));

            terrain.Position = new Vector3Df(0, 0, 0);
            terrain.SetMaterialFlag(MaterialFlag.Lighting, true);
            Scene.MeshManipulator.SetVertexColors(terrain.Mesh, new Color(220, 220, 220));
            selector = Scene.CreateOctreeTriangleSelector(terrain.Mesh, terrain, 128);
            terrain.TriangleSelector = selector;
            Scene.CreateCollisionResponseAnimator(selector, terrain);

            _cam = new Camera(this);

            selectionCube = Scene.AddCubeSceneNode(10, null, -1);
            selectionCube.SetMaterialFlag(MaterialFlag.Wireframe, true);
        }
Exemple #4
0
        static void Main()
        {
            IrrlichtDevice device = IrrlichtDevice.CreateDevice(
                DriverType.Software, new Dimension2Di(640, 480), 16, false, false, false);

            device.SetWindowCaption("Hello World! - Irrlicht Engine Demo");

            VideoDriver    driver = device.VideoDriver;
            SceneManager   smgr   = device.SceneManager;
            GUIEnvironment gui    = device.GUIEnvironment;

            gui.AddStaticText("Hello World! This is the Irrlicht Software renderer!",
                              new Recti(10, 10, 260, 22), true);

            AnimatedMesh          mesh = smgr.GetMesh("../../media/sydney.md2");
            AnimatedMeshSceneNode node = smgr.AddAnimatedMeshSceneNode(mesh);

            if (node != null)
            {
                node.SetMaterialFlag(MaterialFlag.Lighting, false);
                node.SetMD2Animation(AnimationTypeMD2.Stand);
                node.SetMaterialTexture(0, driver.GetTexture("../../media/sydney.bmp"));
            }

            smgr.AddCameraSceneNode(null, new Vector3Df(0, 30, -40), new Vector3Df(0, 5, 0));

            while (device.Run())
            {
                driver.BeginScene(ClearBufferFlag.All, new Color(100, 101, 140));

                smgr.DrawAll();
                gui.DrawAll();

                driver.EndScene();
            }

            device.Drop();
        }
Exemple #5
0
        static void Main()
        {
            DriverType?driverType = AskForDriver();

            if (!driverType.HasValue)
            {
                return;
            }

            IrrlichtDevice device = IrrlichtDevice.CreateDevice(driverType.Value, new Dimension2Di(640, 480));

            if (device == null)
            {
                return;
            }

            VideoDriver    driver = device.VideoDriver;
            SceneManager   smgr   = device.SceneManager;
            GUIEnvironment env    = device.GUIEnvironment;

            // load and display animated fairy mesh
            AnimatedMeshSceneNode fairy = smgr.AddAnimatedMeshSceneNode(smgr.GetMesh("../../media/faerie.md2"));

            if (fairy != null)
            {
                fairy.SetMaterialTexture(0, driver.GetTexture("../../media/faerie2.bmp")); // set diffuse texture
                fairy.SetMaterialFlag(MaterialFlag.Lighting, true);                        // enable dynamic lighting
                fairy.GetMaterial(0).Shininess = 20.0f;                                    // set size of specular highlights
                fairy.Position = new Vector3Df(-10, 0, -100);
                fairy.SetMD2Animation(AnimationTypeMD2.Stand);
            }

            // add white light
            smgr.AddLightSceneNode(null, new Vector3Df(-15, 5, -105), new Colorf(1, 1, 1));

            // set ambient light
            smgr.AmbientLight = new Colorf(0.25f, 0.25f, 0.25f);

            // add fps camera
            CameraSceneNode fpsCamera = smgr.AddCameraSceneNodeFPS();

            fpsCamera.Position = new Vector3Df(-50, 50, -150);

            // disable mouse cursor
            device.CursorControl.Visible = false;

            // create test cube
            SceneNode test = smgr.AddCubeSceneNode(60);

            // let the cube rotate and set some light settings
            SceneNodeAnimator anim = smgr.CreateRotationAnimator(new Vector3Df(0.3f, 0.3f, 0));

            test.Position = new Vector3Df(-100, 0, -100);
            test.SetMaterialFlag(MaterialFlag.Lighting, false);             // disable dynamic lighting
            test.AddAnimator(anim);
            anim.Drop();

            // create render target
            Texture         rt       = null;
            CameraSceneNode fixedCam = null;

            if (driver.QueryFeature(VideoDriverFeature.RenderToTarget))
            {
                rt = driver.AddRenderTargetTexture(new Dimension2Di(256), "RTT1");
                test.SetMaterialTexture(0, rt);                 // set material of cube to render target

                // add fixed camera
                fixedCam = smgr.AddCameraSceneNode(null, new Vector3Df(10, 10, -80), new Vector3Df(-10, 10, -100));
            }
            else
            {
                // create problem text
                GUIFont font = env.GetFont("../../media/fonthaettenschweiler.bmp");
                if (font != null)
                {
                    env.Skin.SetFont(font);
                }

                GUIStaticText text = env.AddStaticText(
                    "Your hardware or this renderer is not able to use the " +
                    "render to texture feature. RTT Disabled.",
                    new Recti(150, 20, 470, 60));

                text.OverrideColor = new Color(255, 255, 255, 100);
            }

            int lastFPS = -1;

            while (device.Run())
            {
                if (device.WindowActive)
                {
                    driver.BeginScene(ClearBufferFlag.All, new Color(0));

                    if (rt != null)
                    {
                        // draw scene into render target

                        // set render target texture
                        driver.SetRenderTarget(rt, ClearBufferFlag.All, new Color(0, 0, 255));

                        // make cube invisible and set fixed camera as active camera
                        test.Visible      = false;
                        smgr.ActiveCamera = fixedCam;

                        // draw whole scene into render buffer
                        smgr.DrawAll();

                        // set back old render target
                        // The buffer might have been distorted, so clear it
                        driver.SetRenderTarget(null, ClearBufferFlag.All, new Color(0));

                        // make the cube visible and set the user controlled camera as active one
                        test.Visible      = true;
                        smgr.ActiveCamera = fpsCamera;
                    }

                    // draw scene normally
                    smgr.DrawAll();
                    env.DrawAll();

                    driver.EndScene();

                    // display frames per second in window title
                    int fps = driver.FPS;
                    if (lastFPS != fps)
                    {
                        device.SetWindowCaption(String.Format(
                                                    "Render to Texture and Specular Highlights example - Irrlicht Engine [{0}] fps: {1}",
                                                    driver.Name, fps));

                        lastFPS = fps;
                    }
                }
            }

            device.Drop();
        }
Exemple #6
0
        /// <summary>
        /// Létrehoz egy sizex*sizey méretű ablakot, windowCaption címmel és deviceType renderelési eszközzel.
        /// </summary>
        /// <param name="windowCaption">Ablak címe</param>
        /// <param name="sizex">Ablak szélessége</param>
        /// <param name="sizey">Ablak magassága</param>
        /// <param name="deviceType">A render eszköz típusa ("DriverType.OpenGL;" (OpenGL) vagy "DriverType.Direct3D8;"/"DriverType.Direct3D9;" (DirectX))</param>
        /// <param name="mapName">Betöltendő pálya neve a kiterjesztés nélkül (pl. "devmap")</param>
        /// <param name="pak0">A pak0 fájl neve (pl. "pak0" vagy "pack1")</param>
        /// <param name="pak1">A pak1 fájl neve (pl. "pak1" vagy "pack4")</param>
        /// <param name="pak2">A pak2 fájl neve (pl. "pak2" vagy "pack2")</param>
        public static void createScreen(string windowCaption, int sizex, int sizey, DriverType deviceType, string mapName, string pak0, string pak1, string pak2, bool isFullScreen)
        {
            //Ablakot megjeleníteni
            if (isFullScreen == true)
            {
                device = IrrlichtDevice.CreateDevice(deviceType, new Dimension2Di(sizex, sizey), 32, true, false, true);
            }
            else
            {
                device = IrrlichtDevice.CreateDevice(deviceType, new Dimension2Di(sizex, sizey), 32, false, false, true);
            }
            if (device == null)
                return;

            AnimatedMesh q3levelmesh = null;
            device.OnEvent += new IrrlichtDevice.EventHandler(device_OnEvent);
            device.SetWindowCaption(Property.modName + " Build " + Property.modVersion);
            driver = device.VideoDriver;
            smgr = device.SceneManager;

            GUIEnvironment gui = device.GUIEnvironment;
            //fadein
            GUIInOutFader fader = device.GUIEnvironment.AddInOutFader();
            fader.SetColor(new Color(0, 0, 0, 255));
            fader.FadeIn(2000);
            //hurtOverlay = device.GUIEnvironment.AddImage(driver.GetTexture("./Content/2D/Overlays/hurt.png"), new Vector2Di(0, 0));
            //hurtOverlay.Visible = false;
            GUIImage copyrightScreen = device.GUIEnvironment.AddImage(driver.GetTexture("./Content/2D/exit.tga"), new Vector2Di(0, 0));
            float guiScalex = sizex / 800;
            float guiScaley = sizey / 600;
            copyrightScreen.Visible = false;
            copyrightScreen.ScaleImage = true;
            copyrightScreen.SetMaxSize(new Dimension2Di(sizex, sizey));
            copyrightScreen.SetMinSize(new Dimension2Di(sizex, sizey));
            //Betölteni a mapot
            try
            {
                device.FileSystem.AddFileArchive("./Content/PK3/" + pak0 + ".edsf");
            }
            catch (Exception ex)
            {
                Logger.Log("pak0 fajl betoltese sikertelen vagy nem talalhato, a jatek nem tud betoltodni");
                string error = ex.ToString();
                    Logger.Log(error);
                Environment.Exit(0);
            }
            try
            {
                device.FileSystem.AddFileArchive("./Content/PK3/" + pak1 + ".edsf");
            }
            catch (Exception ex)
            {
                Logger.Log("pak1 fajl betoltese sikertelen vagy nem talalhato, ignoralva");
                string error = ex.ToString();
                    Logger.Log(error);
            }
            try
            {
                device.FileSystem.AddFileArchive("./Content/PK3/" + pak2 + ".edsf");
            }
            catch (Exception ex)
            {
                Logger.Log("pak2 fajl betoltese sikertelen vagy nem talalhato, ignoralva");
                string error = ex.ToString();
                    Logger.Log(error);
            }
            try
            {
                q3levelmesh = smgr.GetMesh(mapName + ".bsp");
            }
            catch (Exception ex)
            {
                Logger.Log("Palya betoltese sikertelen vagy nem talalhato, a jatek nem tud betoltodni");
                string error = ex.ToString();
                Logger.Log(error);
                Environment.Exit(0);
            }
            MeshSceneNode q3node = null;
                q3node = smgr.AddOctreeSceneNode(q3levelmesh.GetMesh(0), null, IDFlag_IsPickable);
                q3node.Position = new Vector3Df(-1350, -130, -1400);
            SceneNode node = null;
            if (mapName == "rpg")
            {
                IsRPG = true;
            }
            //LightSceneNode light = smgr.AddLightSceneNode(q3node, new Vector3Df(-1319, -118, -1410), new Color(255, 255, 255), 600.0, 10);
            //Half-Life Headcrab
            AnimatedMeshSceneNode anode3 = smgr.AddAnimatedMeshSceneNode(smgr.GetMesh("./Content/3D/headcrab.mdl"));
            if (IsRPG)
            {
                anode3.Position = new Vector3Df(-1212, -180, -1346);
                Audio.playWave("./Content/Music/rpg.mp3");
            }
            else
            {
                anode3.Position = new Vector3Df(-1372.951f, -145.9882f, -1319.71f);
            }
            anode3.Rotation = new Vector3Df(0, 0, 0);
            anode3.AnimationSpeed = 1;
            Scenes.changeAnimation(anode3, 1, 31);
            anode3.SetMaterialFlag(MaterialFlag.Lighting, true);
            anode3.GetMaterial(0).NormalizeNormals = true;
            anode3.GetMaterial(0).Lighting = false;
            //Yodan
            anode2 = smgr.AddAnimatedMeshSceneNode(smgr.GetMesh("./Content/3D/yodan.mdl"));
            anode2.Position = new Vector3Df(-1355, -200, -1410);
            anode2.AnimationSpeed = 15;
            anode2.SetMaterialFlag(MaterialFlag.Lighting, true);
            anode2.GetMaterial(0).NormalizeNormals = true;
            anode2.GetMaterial(0).Lighting = false;
            anode2.SetTransitionTime(3);
               			Scenes.changeYodanAnimation(anode2, "idle");
            //SkyBox
            SceneNode skybox = smgr.AddSkyBoxSceneNode("./Contents/2D/Skybox/mountains_up.jpg", "./Contents/2D/Skybox/mountains_dn.jpg", "./Contents/2D/Skybox/mountains_lf.jpg", "./Contents/2D/Skybox/mountains_rt.jpg", "./Contents/2D/Skybox/mountains_ft.jpg", "./Contents/2D/Skybox/mountains_bk.jpg");
            skybox.Visible = true;
            //FPS kamera hozzáadása
            camera = smgr.AddCameraSceneNodeFPS();
            camera.Position = new Vector3Df(-1625.723f, -145.9937f, -1532.087f);
            camera.Target = new Vector3Df(-1491.555f, -1434.106f, -1368.737f);
            //fegyver
            AnimatedMesh weaponmesh = smgr.GetMesh("./Content/3D/blades.mdl");
            AnimatedMeshSceneNode weapon = smgr.AddAnimatedMeshSceneNode(weaponmesh, camera, 30);
            weapon.Scale = new Vector3Df(0.5f, 0.5f, 0.5f);
            weapon.Position = new Vector3Df(0, 0, 15);
            weapon.Rotation = new Vector3Df(0, -90, 0);
            Scenes.changeAnimation(weapon, 1, 1);
            weapon.Visible = true;
            //fizika
            TriangleSelector selector;
            selector = smgr.CreateOctreeTriangleSelector(q3levelmesh.GetMesh(0), q3node, 128);
            q3node.TriangleSelector = selector;
            anim = smgr.CreateCollisionResponseAnimator(selector, camera, new Vector3Df(30, 50, 30), new Vector3Df(0, -10, 0), new Vector3Df(0, 30, 0));
            //Overlay
            GUIImage overlay = device.GUIEnvironment.AddImage(driver.GetTexture("./Content/2D/Overlays/vignette.png"), new Vector2Di(0, 0));
            overlay.ScaleImage = true;
            overlay.SetMaxSize(new Dimension2Di(sizex, sizey));
            overlay.SetMinSize(new Dimension2Di(sizex, sizey));
            selector.Drop();
            camera.AddAnimator(anim);
            anim.Drop();
            // fény
            lightMovementHelperNode = smgr.AddEmptySceneNode();

            q3node = smgr.AddSphereSceneNode(2, 6, lightMovementHelperNode, -1, new Vector3Df(15, -10, 15));
            q3node.SetMaterialFlag(MaterialFlag.Lighting, false);

            lightNode = q3node;

            //A Portré
            anode = smgr.AddAnimatedMeshSceneNode(smgr.GetMesh("./Content/3D/portrait.mdl"));
            anode.Position = new Vector3Df(-1177.601f, -137.975f, -1238.015f);
            anode.Rotation = new Vector3Df(0,0,0);
            anode.Scale = new Vector3Df(3);
            anode.AnimationSpeed = 1500;
            anode.SetMaterialFlag(MaterialFlag.Lighting, true);
            anode.GetMaterial(0).NormalizeNormals = true;
            anode.GetMaterial(0).Lighting = false;

            AnimatedMeshSceneNode anode4 = smgr.AddAnimatedMeshSceneNode(smgr.GetMesh("./Content/3D/waiter.mdl"));
            anode4.Position = new Vector3Df(-1130, -375, -1724);
            anode4.Rotation = new Vector3Df(0, -90, 0);
            anode4.Scale = new Vector3Df(2, 2, 2);
            anode4.SetMaterialFlag(MaterialFlag.Lighting, false);
            Scenes.changeAnimation(anode4, 0, 1);

            //Egér elrejtése
            device.CursorControl.Visible = false;
            GUIFont font = device.GUIEnvironment.BuiltInFont;
            SceneCollisionManager collMan = smgr.SceneCollisionManager;
            TextSceneNode headcrabName = smgr.AddTextSceneNode(font, "Yodan Lebegö Headcrab-je <Level 10>", new Color(255, 255, 0), null, anode3.Position + new Vector3Df(0, 25, 0), 0);
            TextSceneNode waiterName = smgr.AddTextSceneNode(font, "John <Level 15>", new Color(0, 255, 0), null, anode4.Position + new Vector3Df(0, 125, 0), 0);
            uint then = device.Timer.Time;
            float MOVEMENT_SPEED = 100.0f;

            //Energiagömb
            /*AnimatedMeshSceneNode anode5 = smgr.AddAnimatedMeshSceneNode(smgr.GetMesh("./Content/3D/core.mdl"));
            anode5.Position = new Vector3Df(-1355, 0, -1410);
            Scenes.changeAnimation(anode5, 0, 90);
            anode5.Scale = new Vector3Df(2.0f);
            Line3Df coreray = new Line3Df(-1355, 0, -1410, -1355, -500, -1410);
            driver.SetMaterial(anode5.GetMaterial(1));
            driver.SetTransform(TransformationState.World, Matrix.Identity);
            driver.Draw3DLine(coreray, new Color(255,0,0));*/

            GUIImage bartenderForm = device.GUIEnvironment.AddImage(driver.GetTexture("./Content/2D/bartender.png"), new Vector2Di(10, 10));
            bartenderForm.ScaleImage = true;
            bartenderForm.Visible = false;
            bartenderForm.SetMinSize(new Dimension2Di(sizex - 10, sizey - 10));
            bartenderForm.SetMaxSize(new Dimension2Di(sizex - 10, sizey - 10));
            bool BartenderFormIsOpen = false;
            GUIImage ActionBar = device.GUIEnvironment.AddImage(driver.GetTexture("./Content/2D/Hud/Actionbar.tga"), new Vector2Di(0, 600 - 128));
            //330, 110  790, 120
            Recti expbarrect = new Recti();
            ExperienceBar expbar = new ExperienceBar(gui, expbarrect,0, ActionBar);
            expbar.SetProgress(0);
            expbar.SetColors(new Color(255, 255, 0), new Color(255, 255, 255));
            expbar.AddBorder(5, new Color(0, 0, 0));
            expbar.SetMinSize(new Dimension2Di(128, 64));
            expbar.SetMaxSize(new Dimension2Di(128, 64));
            //Mi minek a része
            q3node.AddChild(anode);
            q3node.AddChild(anode2);
            q3node.AddChild(anode3);
            q3node.AddChild(anode4);
            TextSceneNode yodanName = smgr.AddTextSceneNode(font, "Yodan a Bérgyilkos <Level 90>", new Color(255, 0, 0), null, anode2.Position + new Vector3Df(0, 50, 0), 0);
            while (device.Run())
            {
                driver.BeginScene(true, true, new Color(135, 206, 235));

                smgr.DrawAll();
                gui.DrawAll();
                string printDate = dateTime.ToShortTimeString();
                uint now = device.Timer.Time;
                float frameDeltaTime = (float)(now - then) / 1000.0f;
                then = now;
                Vector3Df nodePosition = camera.Position;
                if (font != null)
                {
                    /*font.Draw("Build " + Property.modVersion, 5, 5, new Color(0, 0, 255));
                    font.Draw("pos= " + camera.Position, 5, 578 - 16, new Color(0, 0, 255));
                    font.Draw("tar= " + camera.Target, 5, 594 - 16, new Color(0, 0, 255));*/
                    font.Draw(Player.Experience(), new Vector2Di(505, 582), new Color(0,0,0));
                }
                if (camera.Position.Z >= 10000)
                {
                    font.Draw("Kiestél a Világból!", new Vector2Di(400, 300), new Color (0, 0, 0));
                    camera.Position = anode.Position;
                }

                if (Quest1Done)
                {
                    yodanName.SetTextColor(new Color(255, 255, 0));
                }

                if (IsKeyDown(KeyCode.Space))
                {
                    nodePosition.Y += MOVEMENT_SPEED * frameDeltaTime;
                }
                else if (IsKeyDown(KeyCode.LControl))
                {
                    nodePosition.Y -= MOVEMENT_SPEED * frameDeltaTime;
                }
                if (IsKeyDown(KeyCode.LShift))
                {
                    MOVEMENT_SPEED = 200.0f;
                }
                else
                {
                    MOVEMENT_SPEED = 100.0f;
                }

                if (IsKeyDown(KeyCode.Esc))
                {
                    copyrightScreen.Visible = true;
                }
                if (IsKeyDown(KeyCode.KeyM))
                {
                    //Yodan.Run(new Vector3Df(-1642, -172, -1421), new Vector3Df(-1053, -167, -1416));
                }
                if (IsKeyDown(KeyCode.KeyB))
                {
                   // Yodan.Wave();

                   Scripting.RunScript(Scripting.LoadScript());
                }
                if (IsKeyDown(KeyCode.KeyV))
                {
                    //Yodan.Speak("./Content/Sound/vo/yodan/yo_20ft.mp3");
                }
                else if (IsKeyDown(KeyCode.KeyN))
                {
                    //Yodan.Stand();
                }
                else if (IsKeyDown(KeyCode.KeyC))
                {
                    //Yodan.WaveAndGreet();
                }
                //Actionbar START

                //Auto-Attack
                if (IsKeyDown(KeyCode.Key1))
                {
                    if (!AutoAttack)
                    {
                        Delay(100);
                        AutoAttack = true;
                        if (currentWeapon == 1)
                        {
                            Scenes.changeAnimation(weapon, 11 + 24 + 25, 11 + 24 + 25 + 31 + 30);
                        }
                        else if (currentWeapon == 2)
                        {
                            Scenes.changeAnimation(weapon, 91 + 31 + 81 + 31, 91 + 31 + 81 + 31+90);
                        }
                    }
                    else if (AutoAttack)
                    {
                        Delay(100);
                        AutoAttack = false;
                        if (currentWeapon == 1)
                        {
                            Scenes.changeAnimation(weapon, 1, 1);
                        }
                        else if (currentWeapon == 2)
                        {
                            Scenes.changeAnimation(weapon, 1, 90);
                        }

                    }
                }
                //Blades
                if (IsKeyDown(KeyCode.Key2))
                 {
                     AnimatedMesh bladesmesh = smgr.GetMesh("./Content/3D/blades.mdl");
                     weapon.Mesh = bladesmesh;
                     weapon.Scale = new Vector3Df(0.5f, 0.5f, 0.5f);
                     weapon.Position = new Vector3Df(0, 0, 15);
                     weapon.Rotation = new Vector3Df(0, -90, 0);
                     Scenes.changeAnimation(weapon, 1, 1);
                     currentWeapon = 1;
                 }
                 //Crossbow
                 if (IsKeyDown(KeyCode.Key3))
                 {
                     AnimatedMesh crossbowmesh = smgr.GetMesh("./Content/3D/crossbow.mdl");
                     weapon.Mesh = crossbowmesh;
                     Scenes.changeAnimation(weapon, 1, 90);
                     weapon.Scale = new Vector3Df(3.0f, 3.0f, 3.0f);
                     currentWeapon = 2;

                 }
                 if (IsKeyDown(KeyCode.Key4))
                 {
                     if (IsEtlapPickedUp)
                     {
                         bartenderForm.Visible = true;
                         BartenderFormIsOpen = true;
                         Audio.playWave("./Content/sound/paper_pickup.mp3");
                     }

                 }

                //Actionbar END

                //elteszi/előveszi a fegyvert
                if(IsKeyDown(KeyCode.Tab))
                {
                    if(weaponHolster)
                    {
                    weapon.Visible = false;
                    Audio.playWave("./Content/sound/weapon.mp3");
                    weaponHolster = false;
                    }
                    else
                    {
                    weapon.Visible = true;
                    Audio.playWave("./Content/sound/weapon.mp3");
                    weaponHolster = true;
                    }
                }
                if (IsKeyDown(KeyCode.MouseLButton))
                {
                    AutoAttack = true;
                    if (currentWeapon == 1)
                    {
                        Scenes.changeAnimation(weapon, 11 + 24 + 25, 11 + 24 + 25 + 31 + 30);
                    }
                    else if (currentWeapon == 2)
                    {
                        Scenes.changeAnimation(weapon, 91 + 31 + 81 + 31, 91 + 31 + 81 + 31 + 90);
                    }
                }
                else if (!IsKeyDown(KeyCode.MouseLButton))
                {
                    AutoAttack = false;
                    if (currentWeapon == 1)
                    {
                        Scenes.changeAnimation(weapon, 1, 1);
                    }
                    else if (currentWeapon == 2)
                    {
                        Scenes.changeAnimation(weapon, 1, 90);
                    }
                }

                if (IsKeyDown(KeyCode.KeyX))
                {
                    Texture yodanMissing = driver.GetTexture("./Content/2D/yodanmissing.tga");
                    Dimension2Di yodanMisSiz = yodanMissing.Size;
                    yodanMisSiz = anode.GetMaterial(0).GetTexture(0).Size;
                    anode.SetMaterialTexture(0, yodanMissing);
                }
                if (IsKeyDown(KeyCode.KeyE))
                {
                    //Bartender Johh On-Use
                    Vector3Df camtarget = camera.Target;
                    if (!BartenderFormIsOpen)
                    {
                        if (new Vector3Df(727, 221, -986) <= camtarget)
                        {
                            if (new Vector3Df(763, 276, -2329) >= camtarget)
                            {
                                if (camtarget > new Vector3Df(184, -1843, -1255))
                                {
                                    if (camtarget > new Vector3Df(138, -1837, -2318))
                                    {
                                        bartenderForm.Visible = true;
                                        BartenderFormIsOpen = true;
                                        if (!IsEtlapPickedUp)
                                        {
                                            ActionBar.Image = driver.GetTexture("./Content/2D/Hud/Actionbar_etlap.tga");
                                            Audio.playWave("./Content/sound/vo/waiter_john/teatime.mp3");
                                        }
                                        IsEtlapPickedUp = true;
                                        Audio.playWave("./Content/sound/paper_pickup.mp3");
                                    }
                                }
                            }
                        }
                    }
                    else if (BartenderFormIsOpen)
                    {
                        bartenderForm.Visible = false;
                        BartenderFormIsOpen = false;
                        Audio.playWave("./Content/sound/paper_pickup.mp3");
                    }
                }

                if (IsKeyDown(KeyCode.KeyK))
                {
                    //Yodan.GoGhost();
                }
                if (IsKeyDown(KeyCode.KeyJ))
                {
                    //Yodan.GoNormal();
                }
                if (IsKeyDown(KeyCode.KeyL))
                {

                }
                if (IsKeyDown(KeyCode.F7))
                {
                    Delay(500);
                    takeScreenshot(device);
                }
                if (IsKeyDown(KeyCode.F9))
                {
                    Delay(500);
                    string campos = camera.Position.ToString();
                    Logger.Log("position:" + campos);
                    string camtar = camera.Target.ToString();
                    Logger.Log("target: " + camtar);
                }
                if (IsKeyDown(KeyCode.LShift))
                {
                    if (IsKeyDown(KeyCode.KeyY))
                    {
                        Environment.Exit(0);
                    } else if (IsKeyDown(KeyCode.KeyN))
                    {
                        copyrightScreen.Visible = false;
                    }
                }

                camera.Position = nodePosition;
                driver.EndScene();
            }
            device.Drop();
        }
        private static float _playerVerticalSpeed = 0.0f; // used to calculate vertical speed for gravity and jump
        static void Main(string[] args)
        {
            IrrlichtDevice device = IrrlichtDevice.CreateDevice(DriverType.OpenGL, new Dimension2Di(ResolutionX, ResolutionY), 24, false, false, false);

            device.OnEvent += Device_OnEvent;
            device.SetWindowCaption("Hello World! - Irrlicht Engine Demo");

            VideoDriver  driver = device.VideoDriver;
            SceneManager smgr   = device.SceneManager;

            GUIEnvironment gui = device.GUIEnvironment;

            gui.AddStaticText("Hello World! This is the Irrlicht Software renderer!",
                              new Recti(10, 10, 260, 22), true);

            AnimatedMesh          mesh       = smgr.GetMesh("../../media/sydney.md2");
            AnimatedMeshSceneNode sydneyNode = smgr.AddAnimatedMeshSceneNode(mesh);

            var cubeSceneNode = smgr.AddCubeSceneNode(2.0f);

            cubeSceneNode.Scale    = new Vector3Df(6.0f, 2.0f, 100.0f);
            cubeSceneNode.Position = new Vector3Df(cubeSceneNode.Position.X, GroundAltitude + 0.5f, cubeSceneNode.Position.Z);

            if (sydneyNode != null)
            {
                sydneyNode.SetMaterialFlag(MaterialFlag.Lighting, true);
                sydneyNode.SetMD2Animation(AnimationTypeMD2.Stand);
                sydneyNode.SetMaterialTexture(0, driver.GetTexture("../../media/sydney.bmp"));
            }

            var lightSceneNode = smgr.AddLightSceneNode();
            var light          = lightSceneNode.LightData;

            light.DiffuseColor = new Colorf(0.8f, 1.0f, 1.0f);
            light.Type         = LightType.Directional;
            light.Position     = new Vector3Df(0.0f, 5.0f, 5.0f);


            var cam = smgr.AddCameraSceneNode(null, new Vector3Df(20, 30, -40), new Vector3Df(20, 5, 0));

            device.Timer.Start();

            uint then = device.Timer.RealTime;

            while (device.Run())
            {
                // As the game is simple we will handle our simple physics ourselves
                uint  now            = device.Timer.RealTime;
                uint  elapsed        = now - then;
                float elapsedTimeSec = (float)elapsed / 1000.0f;
                then = now;

                // we target 58.8 FPS
                if (elapsed < 17)
                {
                    device.Sleep(17 - (int)elapsed);
                }
                else
                {
                    // uh-oh, it took more than .125 sec to do render loop!
                    // what do we do now?
                }

                _playerVerticalSpeed += elapsedTimeSec * -(VerticalGravity * 10.0f);

                var calculatedNewPos = sydneyNode.Position - new Vector3Df(0.0f, _playerVerticalSpeed * elapsedTimeSec, 0.0f);

                float offsetSydney = sydneyNode.BoundingBox.Extent.Y / 2.0f;
                _isGrounded = calculatedNewPos.Y <= (GroundAltitude + offsetSydney);
                if (_isGrounded)
                {
                    _playerVerticalSpeed = 0.0f;
                    calculatedNewPos.Y   = GroundAltitude + offsetSydney;
                }
                else
                {
                    calculatedNewPos.Y = calculatedNewPos.Y;
                }

                sydneyNode.Position = calculatedNewPos;

                driver.BeginScene(true, true, new Color(100, 101, 140));
                smgr.DrawAll();
                gui.DrawAll();

                driver.EndScene();
            }

            device.Drop();
        }
Exemple #8
0
        static void Main(string[] args)
        {
            DriverType driverType;

            if (!AskUserForDriver(out driverType))
            {
                return;
            }

            IrrlichtDevice device = IrrlichtDevice.CreateDevice(driverType, new Dimension2Di(ResX, ResY), 32, fullScreen);

            if (device == null)
            {
                return;
            }

            device.OnEvent += new IrrlichtDevice.EventHandler(device_OnEvent);
            VideoDriver  driver = device.VideoDriver;
            SceneManager smgr   = device.SceneManager;

            // load model
            AnimatedMesh model = smgr.GetMesh("../../media/sydney.md2");

            if (model == null)
            {
                return;
            }

            AnimatedMeshSceneNode model_node = smgr.AddAnimatedMeshSceneNode(model);

            // load texture
            if (model_node != null)
            {
                Texture texture = driver.GetTexture("../../media/sydney.bmp");
                model_node.SetMaterialTexture(0, texture);
                model_node.SetMD2Animation(AnimationTypeMD2.Run);
                model_node.SetMaterialFlag(MaterialFlag.Lighting, false);
            }

            // load map
            device.FileSystem.AddFileArchive("../../media/map-20kdm2.pk3");
            AnimatedMesh map = smgr.GetMesh("20kdm2.bsp");

            if (map != null)
            {
                SceneNode map_node = smgr.AddOctreeSceneNode(map.GetMesh(0));
                map_node.Position = new Vector3Df(-850, -220, -850);
            }

            // create 3 fixed and one user-controlled cameras
            camera[0]          = smgr.AddCameraSceneNode(null, new Vector3Df(50, 0, 0), new Vector3Df(0)); // font
            camera[1]          = smgr.AddCameraSceneNode(null, new Vector3Df(0, 50, 0), new Vector3Df(0)); // top
            camera[2]          = smgr.AddCameraSceneNode(null, new Vector3Df(0, 0, 50), new Vector3Df(0)); // left
            camera[3]          = smgr.AddCameraSceneNodeFPS();                                             // user-controlled
            camera[3].Position = new Vector3Df(-50, 0, -50);

            device.CursorControl.Visible = false;

            int lastFPS = -1;

            while (device.Run())
            {
                // set the viewpoint to the whole screen and begin scene
                driver.ViewPort = new Recti(0, 0, ResX, ResY);
                driver.BeginScene(true, true, new Color(100, 100, 100));

                if (splitScreen)
                {
                    smgr.ActiveCamera = camera[0];
                    driver.ViewPort   = new Recti(0, 0, ResX / 2, ResY / 2);                   // top left
                    smgr.DrawAll();

                    smgr.ActiveCamera = camera[1];
                    driver.ViewPort   = new Recti(ResX / 2, 0, ResX, ResY / 2);                   // top right
                    smgr.DrawAll();

                    smgr.ActiveCamera = camera[2];
                    driver.ViewPort   = new Recti(0, ResY / 2, ResX / 2, ResY);                   // bottom left
                    smgr.DrawAll();

                    driver.ViewPort = new Recti(ResX / 2, ResY / 2, ResX, ResY);                     // bottom right
                }

                smgr.ActiveCamera = camera[3];
                smgr.DrawAll();

                driver.EndScene();

                int fps = driver.FPS;
                if (lastFPS != fps)
                {
                    device.SetWindowCaption(String.Format(
                                                "Split Screen example - Irrlicht Engine [{0}] fps: {1}",
                                                driver.Name, fps));

                    lastFPS = fps;
                }
            }

            device.Drop();
        }