예제 #1
0
 public structModel(VertexBuffer VertexBuffer, structVertex[] Sommets, int nbfaces, string map_Kd, string map_Ns, Matrix Transformation)
 {
     this.VertexBuffer = VertexBuffer;
     this.Sommets = Sommets;
     this.nbfaces = nbfaces;
     this.map_Kd = map_Kd;
     this.map_Ns = map_Ns;
     this.Transformation = Transformation;
 }
예제 #2
0
        public static List<structModel> read_obj(byte[] obj, Matrix transformation)
        {
            List<structModel> Liste_Models = new List<structModel>();
            int i = 0, nbsommets = 0, nbtextures = 0, nbnormales = 0;
            int material_used = 0;
            int precedent_pourcentage = 0;
            Program.WriteNicely("#", 2, "Ouverture du fichier " + obj[0].ToString());
            structModel model_actuel = new structModel(Program.VertexBufferZero, new structVertex[0], 0, "null.bmp", "null.bmp", transformation);

            ///////////// Pour la construction des sommets /////////////
            List<Vector2> ListeCoordTextures = new List<Vector2>();
            List<Vector4> ListeCoordSommets = new List<Vector4>();
            List<Vector4> ListeNormales = new List<Vector4>();

            ///////////// Sommets /////////////
            List<structVertex> ListeVertex = new List<structVertex>();
            //List<Vertex[]> ListeVerticesComplete_avec_differentes_textures_separee = new List<Vertex[]>();

            float x = 1, y = 1, z = 1;
            string type;

            Color3[] couleur = new Color3[3] {
                Color.White.ToColor3(),
                Color.White.ToColor3(),
                Color.White.ToColor3()
            };

            while (i < obj.Length)
            {
                type = getstring(ref i, ref obj);
                #region sommet
                if (type == "v")
                {
                    nbsommets++;
                    // On recupère les coordonnées du sommet
                    i++; // espace
                    x = getfloat(ref i, ref obj); // Coord x
                    i++; // espace
                    y = getfloat(ref i, ref obj); // Coord y
                    i++; // espace
                    z = getfloat(ref i, ref obj); // Coord z

                    // Ajout dans la liste le nouveau sommet
                    ListeCoordSommets.Add(new Vector4(x, y, z, 1));

                    // DEBUG
                    //string abc = "Nouveau sommet " + x + " " + y + " " + z;
                    //Program.WriteNicely("#", 3, abc);
                }
                #endregion
                #region textures
                else if (type == "vt")
                {
                    nbtextures++;
                    // On recupère les coordonnées de texture
                    i++; // espace
                    x = getfloat(ref i, ref obj); // Coord x
                    i++; // espace
                    y = getfloat(ref i, ref obj); // Coord y

                    // Ajout dans la liste la nouvelle texture
                    ListeCoordTextures.Add(new Vector2(x, y));

                    // DEBUG
                    //string abc = "Nouvelle texture " + x + " " + y;
                    //Program.WriteNicely("#", 3, abc);
                }
                #endregion
                #region normales
                else if (type == "vn")
                {
                    nbnormales++;
                    // On recupère les normales
                    i++; // espace
                    x = getfloat(ref i, ref obj); // Coord x
                    i++; // espace
                    y = getfloat(ref i, ref obj); // Coord y
                    i++; // espace
                    z = getfloat(ref i, ref obj); // Coord z

                    // Ajout dans la liste des normales
                    ListeNormales.Add(new Vector4(x, y, z, 1));

                    // DEBUG
                    //string abc = "Nouvelle normale " + x + " " + y;
                    //Program.WriteNicely("#", 3, abc);
                }
                #endregion
                #region faces
                else if (type == "f")
                {
                    structVertex[] face = new structVertex[3];
                    bool testing = false;
                    if (mtlloader.MTLData.Count == 0)
                    {
                        testing = true;
                        mtlloader.MTLData.Add(new structMTL("", Color.White, Color.White, Color.White, "null.bmp", "null.bmp"));
                    }
                    model_actuel.nbfaces++;
                    //string abc;
                    // CONSTRUCTION SOMMET 1
                    // On recupère les info du sommet
                    i++; // espace
                    x = getfloat(ref i, ref obj); // Coord x
                    i++; // slash
                    y = getfloat(ref i, ref obj); // Coord y
                    i++; // slash
                    z = getfloat(ref i, ref obj); // Coord z
                    face[0] = (new structVertex()
                    {
                        Position = new Vector4(
                            ListeCoordSommets[Convert.ToInt32(x - 1)].X,
                            ListeCoordSommets[Convert.ToInt32(x - 1)].Y,
                            ListeCoordSommets[Convert.ToInt32(x - 1)].Z,
                            ListeCoordSommets[Convert.ToInt32(x - 1)].W
                        ),
                        CoordTextures = new Vector2(
                            ListeCoordTextures[Convert.ToInt32(y - 1)].X,
                            ListeCoordTextures[Convert.ToInt32(y - 1)].Y
                        ),
                        Color = mtlloader.MTLData[material_used].Kd.ToVector4(),
                        Normal = new Vector4(
                            ListeNormales[Convert.ToInt32(z - 1)].X,
                            ListeNormales[Convert.ToInt32(z - 1)].Y,
                            ListeNormales[Convert.ToInt32(z - 1)].Z,
                            1),
                    });
                    //abc = "Construction sommet " + Convert.ToInt32(x-1) + " " + Convert.ToInt32(y-1) + " " + Convert.ToInt32(z-1);
                    //Program.WriteNicely("#", 3, abc);

                    // CONSTRUCTION SOMMET 2
                    // On recupère les info du sommet
                    i++; // espace
                    x = getfloat(ref i, ref obj); // Coord x
                    i++; // slash
                    y = getfloat(ref i, ref obj); // Coord y
                    i++; // slash
                    z = getfloat(ref i, ref obj); // Coord z

                    //var abcd = Vector4.Transform(new Vector4(0, 0, 1, 1), Matrix.Multiply(Matrix.RotationY(Convert.ToSingle(-Math.PI / 2)), Matrix.Translation(1, 0, 0)));

                    face[1] = (new structVertex()
                    {
                        Position = new Vector4(
                            ListeCoordSommets[Convert.ToInt32(x - 1)].X,
                            ListeCoordSommets[Convert.ToInt32(x - 1)].Y,
                            ListeCoordSommets[Convert.ToInt32(x - 1)].Z,
                            ListeCoordSommets[Convert.ToInt32(x - 1)].W
                        ),
                        CoordTextures = new Vector2(
                            ListeCoordTextures[Convert.ToInt32(y - 1)].X,
                            ListeCoordTextures[Convert.ToInt32(y - 1)].Y
                        ),
                        Color = mtlloader.MTLData[material_used].Kd.ToVector4(),
                        Normal = new Vector4(
                            ListeNormales[Convert.ToInt32(z - 1)].X,
                            ListeNormales[Convert.ToInt32(z - 1)].Y,
                            ListeNormales[Convert.ToInt32(z - 1)].Z,
                            1),
                    });
                    //abc = "Construction sommet " + Convert.ToInt32(x-1) + " " + Convert.ToInt32(y-1) + " " + Convert.ToInt32(z-1);
                    //Program.WriteNicely("#", 3, abc);

                    // CONSTRUCTION SOMMET 3
                    // On recupère les info du sommet
                    i++; // espace
                    x = getfloat(ref i, ref obj); // Coord x
                    i++; // slash
                    y = getfloat(ref i, ref obj); // Coord y
                    i++; // slash
                    z = getfloat(ref i, ref obj); // Coord z
                    face[2] = (new structVertex()
                    {
                        Position = new Vector4(
                            ListeCoordSommets[Convert.ToInt32(x - 1)].X,
                            ListeCoordSommets[Convert.ToInt32(x - 1)].Y,
                            ListeCoordSommets[Convert.ToInt32(x - 1)].Z,
                            ListeCoordSommets[Convert.ToInt32(x - 1)].W
                        ),
                        CoordTextures = new Vector2(
                            ListeCoordTextures[Convert.ToInt32(y - 1)].X,
                            ListeCoordTextures[Convert.ToInt32(y - 1)].Y
                        ),
                        Color = mtlloader.MTLData[material_used].Kd.ToVector4(),
                        Normal = new Vector4(
                            ListeNormales[Convert.ToInt32(z - 1)].X,
                            ListeNormales[Convert.ToInt32(z - 1)].Y,
                            ListeNormales[Convert.ToInt32(z - 1)].Z,
                            1),
                    });

                    Vector4 Tangent = CalcTangentVector(
                        new Vector3[] {
                        new Vector3(face[0].Position.X, face[0].Position.Y, face[0].Position.Z),
                        new Vector3(face[1].Position.X, face[1].Position.Y, face[1].Position.Z),
                        new Vector3(face[2].Position.X, face[2].Position.Y, face[2].Position.Z),
                    },
                        new Vector2[] {
                        new Vector2(face[0].CoordTextures.X, face[0].CoordTextures.Y),
                        new Vector2(face[1].CoordTextures.X, face[1].CoordTextures.Y),
                        new Vector2(face[2].CoordTextures.X, face[2].CoordTextures.Y),
                    },
                        new Vector3(face[0].Normal.X, face[0].Normal.Y, face[0].Normal.Z));

                    face[0].Tangent = Tangent;
                    face[1].Tangent = Tangent;
                    face[2].Tangent = Tangent;
                    if (mtlloader.MTLData[material_used].map_Ns != "null.bmp")
                    {
                        face[0].bool_normal_map = 1;
                        face[1].bool_normal_map = 1;
                        face[2].bool_normal_map = 1;
                    }
                    else
                    {
                        face[0].bool_normal_map = -1;
                        face[1].bool_normal_map = -1;
                        face[2].bool_normal_map = -1;
                    }

                    ListeVertex.Add(face[0]);
                    ListeVertex.Add(face[1]);
                    ListeVertex.Add(face[2]);

                    //abc = "Construction sommet " + Convert.ToInt32(x-1) + " " + Convert.ToInt32(y-1) + " " + Convert.ToInt32(z-1);
                    //Program.WriteNicely("#", 3, abc);
                    if (testing)
                        mtlloader.MTLData.Clear();
                }
                #endregion
                #region objet
                else if (type == "o") // S'il s'agit d'un nouvel objet on ne fait rien
                {
                    i++;
                    Program.WriteNicely("#", 3, "Nouvel objet : " + getstring(ref i, ref obj));
                }
                #endregion
                #region groupe
                else if (type == "g") // S'il s'agit d'un nouveau groupe on ne fait rien
                {
                    i++;
                    Program.WriteNicely("#", 3, "Nouveau groupe : " + getstring(ref i, ref obj));
                }
                #endregion
                #region material
                else if (type == "mtllib") // S'il s'agit d'un nouveau fichier mtl on le lit et on le stocke
                {
                    i++;
                    string abc = getstring(ref i, ref obj);
                    Program.WriteNicely("\t#", 11, "Nouveau fichier .MTL : " + abc);
                    mtlloader.read_mtl(abc, @"Ressources/Game/");
                }
                else if (type == "usemtl")
                {
                    i++;
                    string abc = getstring(ref i, ref obj);
                    Program.WriteNicely("#", 11, "utilisation de : " + abc);
                    if (model_actuel.nbfaces != 0)
                    {
                        model_actuel.Sommets = ListeVertex.ToArray();
                        model_actuel.map_Kd = mtlloader.MTLData[material_used].map_Kd;
                        model_actuel.map_Ns = mtlloader.MTLData[material_used].map_Ns;
                        model_actuel.VertexBuffer = new VertexBuffer(Program.device,
                            (
                                Utilities.SizeOf<structVertex>() // NORMAL
                            ) * 3 * model_actuel.nbfaces, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
                        ListeVertex.Clear();
                        Liste_Models.Add(model_actuel);
                        model_actuel = new structModel(Program.VertexBufferZero, new structVertex[0], 0, "null.bmp", "null.bmp", transformation);
                    }
                    for (int j = 0; j < mtlloader.MTLData.Count; j++)
                    {
                        if (mtlloader.MTLData[j].name == abc)
                        {
                            material_used = j;
                            j = mtlloader.MTLData.Count;
                        }
                    }
                }
                else if (type == "s")
                {
                    //Program.WriteNicely("#", 11, "Lissage OFF");
                }
                #endregion
                else if (type == "")
                {
                    Program.WriteNicely("#", 5, "Ligne vide");
                }
                #region commentaire
                else if (type[0] == '#')
                {
                    Program.WriteNicely("#", 4, "Nouveau commentaire");
                }
                #endregion
                else
                {
                    Program.WriteNicely("!", 2, "Type inconnu");
                }

                // FIN DU TRAITEMENT
                if (precedent_pourcentage != Convert.ToInt32(Convert.ToSingle(i) / Convert.ToSingle(obj.Length) * 100))
                {
                    precedent_pourcentage = Convert.ToInt32(Convert.ToSingle(i) / Convert.ToSingle(obj.Length) * 100);
                    //Console.WriteLine("\t{0} % lu", precedent_pourcentage);
                    //Console.CursorTop--;
                }
                gotonextline(ref i, ref obj);
                //i++;
            }
            if (model_actuel.nbfaces != 0)
            {
                mtlloader.MTLData.Add(new structMTL("", Color.White, Color.White, Color.White, "null.bmp", "null.bmp"));
                model_actuel.Sommets = ListeVertex.ToArray();
                model_actuel.map_Kd = mtlloader.MTLData[material_used].map_Kd;
                model_actuel.map_Ns = mtlloader.MTLData[material_used].map_Ns;
                model_actuel.VertexBuffer = new VertexBuffer(Program.device,
                    (
                        Utilities.SizeOf<structVertex>() // NORMAL
                    ) * 3 * model_actuel.nbfaces, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
                mtlloader.MTLData.Clear();
                ListeVertex.Clear();
                Liste_Models.Add(model_actuel);
                //model_actuel = new Model(Program.VertexBufferZero, new Vertex[0], 0, "null.bmp");
            }

            return Liste_Models;
            //return ListeVertex.ToArray();
        }
예제 #3
0
파일: HUD.cs 프로젝트: Arys02/Underground
        /*public void Display_3DHUD()
        {
            VertexBuffer VertexBufferHUD;
            structVertex[] Sommets;
            // Affichage du brouillar
            VertexBufferHUD = new VertexBuffer(Program.device,
                    (
                        Utilities.SizeOf<structVertex>()
                    ) * 3 * 2, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
            Sommets = new structVertex[] {
                    new structVertex() { Position = new Vector4( - 5 , - 1, + 5, 1.0f), CoordTextures = new Vector2(0f, 0f), Normal = new Vector4(0,1,0,1), Color = Color.White.ToVector4() },
                    new structVertex() { Position = new Vector4( + 5 , - 1, + 5, 1.0f), CoordTextures = new Vector2(1f, 0f), Normal = new Vector4(0,1,0,1), Color = Color.White.ToVector4() },
                    new structVertex() { Position = new Vector4( + 5 , - 1, - 5, 1.0f), CoordTextures = new Vector2(1f, 1f), Normal = new Vector4(0,1,0,1), Color = Color.White.ToVector4() },

                    new structVertex() { Position = new Vector4( - 5 , - 1, + 5, 1.0f), CoordTextures = new Vector2(0f, 0f), Normal = new Vector4(0,1,0,1), Color = Color.White.ToVector4() },
                    new structVertex() { Position = new Vector4( + 5 , - 1, - 5, 1.0f), CoordTextures = new Vector2(1f, 1f), Normal = new Vector4(0,1,0,1), Color = Color.White.ToVector4() },
                    new structVertex() { Position = new Vector4( - 5 , - 1, - 5, 1.0f), CoordTextures = new Vector2(0f, 1f), Normal = new Vector4(0,1,0,1), Color = Color.White.ToVector4() },
            };
            VertexBufferHUD.Lock(0, 0, LockFlags.DoNotWait).WriteRange(Sommets);
            VertexBufferHUD.Unlock();
            Program.device.SetStreamSource(0, VertexBufferHUD, 0, Utilities.SizeOf<structVertex>());
            Program.device.SetTexture(0, Program.Liste_textures[Program.getTexture(@"Ressources\HUD\Brouillar.png")].texture);
            Program.device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
            VertexBufferHUD.Dispose();
        }*/
        public void Display_HUD()
        {
            VertexBuffer VertexBufferHUD;
            Program.device.VertexDeclaration = Program.VertexDeclaration2D;
            structVertex[] Sommets;

            foreach (EltInfo Elt in Liste_Elt)
            {
                VertexBufferHUD = new VertexBuffer(Program.device,
                    (
                        Utilities.SizeOf<structVertex>()
                    ) * 3 * 2, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
                if (Elt.EltType == EltType.EyeBar) // Barre de progression des yeux
                {
                    Sommets = new structVertex[] {
                    new structVertex() { Position = new Vector4(Elt.Position.X                                , Elt.Position.Y             , 0f, 1.0f), CoordTextures = new Vector2(0f, 0f) },
                    new structVertex() { Position = new Vector4(Elt.Position.X + Elt.Taille.X * Ingame.percent, Elt.Position.Y             , 0f, 1.0f), CoordTextures = new Vector2(1f, 0f) },
                    new structVertex() { Position = new Vector4(Elt.Position.X                                , Elt.Position.Y+Elt.Taille.Y, 0f, 1.0f), CoordTextures = new Vector2(0f, 1f) },
                    new structVertex() { Position = new Vector4(Elt.Position.X + Elt.Taille.X * Ingame.percent, Elt.Position.Y+Elt.Taille.Y, 0f, 1.0f), CoordTextures = new Vector2(1f, 1f) },
                    new structVertex() { Position = new Vector4(Elt.Position.X + Elt.Taille.X * Ingame.percent, Elt.Position.Y             , 0f, 1.0f), CoordTextures = new Vector2(1f, 0f) }};
                }
                else // Par défaut
                {
                    if (Elt.EltType == EltType.RunBar) // Barre de progression de run
                    {
                        Sommets = new structVertex[] {
                        new structVertex() { Position = new Vector4(Elt.Position.X                                , Elt.Position.Y             , 0f, 1.0f), CoordTextures = new Vector2(0f, 0f) },
                        new structVertex() { Position = new Vector4(Elt.Position.X + Elt.Taille.X * Ingame.percentRun, Elt.Position.Y             , 0f, 1.0f), CoordTextures = new Vector2(1f, 0f) },
                        new structVertex() { Position = new Vector4(Elt.Position.X                                , Elt.Position.Y+Elt.Taille.Y, 0f, 1.0f), CoordTextures = new Vector2(0f, 1f) },
                        new structVertex() { Position = new Vector4(Elt.Position.X + Elt.Taille.X * Ingame.percentRun, Elt.Position.Y+Elt.Taille.Y, 0f, 1.0f), CoordTextures = new Vector2(1f, 1f) },
                        new structVertex() { Position = new Vector4(Elt.Position.X + Elt.Taille.X * Ingame.percentRun, Elt.Position.Y             , 0f, 1.0f), CoordTextures = new Vector2(1f, 0f) }};

                    }
                    else
                    {
                        Sommets = new structVertex[] {
                        new structVertex() { Position = new Vector4(Elt.Position.X               , Elt.Position.Y             , 0f, 1.0f), CoordTextures = new Vector2(0f, 0f) },
                        new structVertex() { Position = new Vector4(Elt.Position.X + Elt.Taille.X, Elt.Position.Y             , 0f, 1.0f), CoordTextures = new Vector2(1f, 0f) },
                        new structVertex() { Position = new Vector4(Elt.Position.X               , Elt.Position.Y+Elt.Taille.Y, 0f, 1.0f), CoordTextures = new Vector2(0f, 1f) },
                        new structVertex() { Position = new Vector4(Elt.Position.X + Elt.Taille.X, Elt.Position.Y+Elt.Taille.Y, 0f, 1.0f), CoordTextures = new Vector2(1f, 1f) },
                        new structVertex() { Position = new Vector4(Elt.Position.X + Elt.Taille.X, Elt.Position.Y             , 0f, 1.0f), CoordTextures = new Vector2(1f, 0f) }};

                    }
                }
                VertexBufferHUD.Lock(0, 0, LockFlags.None).WriteRange(Sommets);
                VertexBufferHUD.Unlock();
                Program.device.SetStreamSource(0, VertexBufferHUD, 0, Utilities.SizeOf<structVertex>());
                Program.device.SetTexture(0, Program.Liste_textures[Program.getTexture(Elt.PathTexture)].texture);
                Program.device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                VertexBufferHUD.Dispose();
            }
            Program.device.VertexDeclaration = Program.VertexDeclaration3D;
        }
예제 #4
0
파일: Menu.cs 프로젝트: Arys02/Underground
        public static void InMenu()
        {
            VertexBuffer VertexBufferMenu;
            Program.device.VertexDeclaration = Program.VertexDeclaration2D;

            if (IsInGame)
            {
                if (Ingame.kill == false)
                {
                    _switchTo = _pauseTab;
                    _tabTmp = _pauseTab;
                }
                else
                {
                    _switchTo = _pauseTab2;
                    _tabTmp = _pauseTab2;
                }
            }

            Switcher();

            string hoveringButton = string.Empty;

            foreach (EltInfo Elt in _tabTmp)
            {
                VertexBufferMenu = new VertexBuffer(Program.device,
                    (
                        Utilities.SizeOf<structVertex>()
                    ) * 3 * 2, Usage.WriteOnly, VertexFormat.None, Pool.Managed);

                var Sommets = new structVertex[] {
                    new structVertex() { Position = new Vector4(Elt.Position.X               , Elt.Position.Y             , 0f, 1.0f), CoordTextures = new Vector2(0f, 0f) },
                    new structVertex() { Position = new Vector4(Elt.Position.X + Elt.Taille.X, Elt.Position.Y             , 0f, 1.0f), CoordTextures = new Vector2(1f, 0f) },
                    new structVertex() { Position = new Vector4(Elt.Position.X               , Elt.Position.Y+Elt.Taille.Y, 0f, 1.0f), CoordTextures = new Vector2(0f, 1f) },
                    new structVertex() { Position = new Vector4(Elt.Position.X + Elt.Taille.X, Elt.Position.Y+Elt.Taille.Y, 0f, 1.0f), CoordTextures = new Vector2(1f, 1f) },
                    new structVertex() { Position = new Vector4(Elt.Position.X + Elt.Taille.X, Elt.Position.Y             , 0f, 1.0f), CoordTextures = new Vector2(1f, 0f) }};
                VertexBufferMenu.Lock(0, 0, LockFlags.None).WriteRange(Sommets);
                VertexBufferMenu.Unlock();
                Program.device.SetStreamSource(0, VertexBufferMenu, 0, Utilities.SizeOf<structVertex>());

                if (Elt.EltType == EltType.Button &&
                       Cursor.Position.X - Program.form.DesktopBounds.X > Elt.Position.X && Cursor.Position.X - Program.form.DesktopBounds.X < Elt.Position.X + Elt.Taille.X &&
                       Cursor.Position.Y - Program.form.DesktopBounds.Y > Elt.Position.Y && Cursor.Position.Y - Program.form.DesktopBounds.Y < Elt.Position.Y + Elt.Taille.Y)
                {
                    Program.device.SetTexture(0, Program.Liste_textures[Program.getTexture(@"Ressources\HUD\button_hover.png")].texture);
                    hoveringButton = Elt.Text;
                }
                else
                {
                    Program.device.SetTexture(0, Program.Liste_textures[Program.getTexture(Elt.PathTexture)].texture);
                }
                Program.device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
                VertexBufferMenu.Dispose();

                if (Elt.Text != String.Empty)
                {
                    font.DrawText(null, Elt.Text, (int)Elt.Position.X + 15, (int)Elt.Position.Y + 5, Color.Gray);
                }
            }

            if (Program.input.MouseLeft && hoveringButton != String.Empty)
            {
                switch (hoveringButton)
                {
                    case "Play":
                        Program.device.VertexDeclaration = new VertexDeclaration(Program.device, Program.vertexElems3D);
                        IsInMenu = false;
                        IsInGame = true;
                        break;
                    case "Settings":
                        _switchTo = _menuTabSettings;
                        break;
                    case "Back":
                        _switchTo = _menuTabMain;
                        break;
                    case "-":
                        Process.Start(Application.ExecutablePath, "-r 800 600");

                        Program.device.Dispose();
                        Program.form.Dispose();
                        Menu.Dispose();

                        Process.GetCurrentProcess().Kill();
                        break;
                    case "+":
                        Process.Start(Application.ExecutablePath, "-r 1366 768");

                        Program.device.Dispose();
                        Program.form.Dispose();
                        Menu.Dispose();

                        Process.GetCurrentProcess().Kill();
                        break;
                    case "+ ":
                        Sound.mastervoice.SetVolume((Sound.mastervoice.Volume < 12)
                                                        ? Sound.mastervoice.Volume + 1
                                                        : Sound.mastervoice.Volume);
                        _tabTmp[11].Text = Get_Volume();
                        break;
                    case "- ":
                        Sound.mastervoice.SetVolume((Sound.mastervoice.Volume > 0)
                                                        ? Sound.mastervoice.Volume - 1
                                                        : Sound.mastervoice.Volume);
                        _tabTmp[11].Text = Get_Volume();
                        break;
                    case "Resume":
                        Program.device.VertexDeclaration = new VertexDeclaration(Program.device, Program.vertexElems3D);
                        IsInMenu = false;
                        IsInGame = true;
                        break;

                    case "Play again":
                        Process.Start(Application.ExecutablePath, "");

                        Program.device.Dispose();
                        Program.form.Dispose();
                        Menu.Dispose();

                        Process.GetCurrentProcess().Kill();
                        break;

                    case "Exit":
                        Program.device.Dispose();
                        Program.form.Dispose();
                        Menu.Dispose();
                        Process.GetCurrentProcess().Kill();
                        break;
                }
            }
            Program.device.VertexDeclaration = Program.VertexDeclaration3D;
        }